#!/usr/bin/python

#  SCHEMATIC
#                
#   [GND]--[R 1kOhm]--+
#                     |
#                     |
#        [RPi-IO_17]--+--[PushButton]--[RPi-3.3V]

import time

try:
    import RPi.GPIO as GPIO
except RuntimeError:
    print "Try running the script as root"

buttonPin = 17                                  # Pin connected to button output

if __name__ == "__main__":
    GPIO.setmode(GPIO.BCM)                      # Use PGIO header pin names
    GPIO.setup(buttonPin,GPIO.IN)               # Defines the pin as digital input

    while GPIO.input(buttonPin) != GPIO.HIGH:   # Wait the button to be pressed to exit the loop
        time.sleep(0.01)                        # Will exits if input is HIGH (when button is pressed)

    print("Button Pushed!")
